package com.mall.items.web.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.mall.items.web.pojo.Item;
import com.mall.manager.pojo.TbItem;
import com.mall.manager.pojo.TbItemDesc;
import com.mall.manager.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import sun.dc.pr.PRError;

/**
 * @author Administrator
 */

@Controller
public class ItemInfoController {

    @Reference
    private ItemService itemService;

    @GetMapping("/item/{itemId}")
    public String showItemInfo(@PathVariable("itemId") long id, Model model){
        TbItem tbitem = itemService.getItemById(id);

        //生成一个自己的item pojo
        Item item = new Item(tbitem);
        //获得商品描述信息
        TbItemDesc itemDesc = itemService.getItemDescById(id);

        model.addAttribute("item",item);
        model.addAttribute("itemDesc",itemDesc);
        return "item";
    }



}
